#
# macros
#
CC = g++
CFLAGS = $(shell pkg-config --cflags opencv)
CFLAGS += -O2
LIBS = $(shell pkg-config --libs opencv)

# 
BUILD = handpie
# to make object files
OBJS = main.o linkedList.o lookup_function.o lookup_h.o lookup_s.o lookup_i.o imgProc.o histogram.o
SRCS = $(OBJS:.o=.cpp)

#
# make targets
#
.PHONY: all clean dep

# build all
all: dep $(BUILD)

# build project main 
$(BUILD): $(OBJS)
	$(CC) $(CFLAGS) $(LIBS) -o $@ $^

# generate dependency file 
dep:
	$(CC) -M $(SRCS) > .depend

# remove all generated by makefile
clean:
	rm -f *.o $(BUILD) .depend

#
# extention rule (automatically compiles .cpp files)
# 
.SUFFIXES: .cpp .o
.cpp.o:
	$(CC) -c -o $@ $<

#
# dependent relationship. If it was changed at least 1 of lists, target will be recompiled.
#
# $(OBJS): $($@:.o=.cpp) hsi_lookup.h makefile
# the above is replaced by the following.
# main.o: main.cpp hsi_lookup.h makefile
# hsi_lookup.o: hsi_lookup.cpp hsi_lookup.h makefile

# include dependency list
ifeq (.depend, $(wildcard .depend))
include .depend
endif
